package com.panasonic.cn.cmsc;

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;
import java.sql.SQLException;
import com.fujitsu.fks.jaaf.core.*;

public class SQLMUSR01{
	private Hashtable paramsString     = new Hashtable();
	private Hashtable paramsBigDecimal = new Hashtable();
	private Hashtable paramsFree       = new Hashtable();
	private String lastSql_ = null;

	private String getString(String name){
		if(name==null) return "";
		String returnStr = (String)paramsString.get(name);
		if(returnStr==null) return "";
		return "'"+FrameworkCommon.stringReplaceSQuote(returnStr)+"'";
	}

	private String getBigDecimal(String name){
		if(name==null) return "";
		BigDecimal returnStr = (BigDecimal)paramsBigDecimal.get(name);
		if(returnStr==null) return "";
		return returnStr.toString();
	}

	private String getFree(String name){
		if(name==null) return "";
		String returnStr = (String)paramsFree.get(name);
		if(returnStr==null) return "";
		return returnStr;
	}

	public String getLastSql(){
		return lastSql_;
	}

	public SelectResultRset SELECT_USR01(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	SELECT USER_ID,");
		sql.append("USER_NAME,");
		sql.append("PASSWORD,");
		sql.append("CTRL_DVSN_CD,");
		sql.append("AUTH_LEVEL,");
		sql.append("BSNS_TYP,");
		sql.append("MAIL_ADDRESS,");
		sql.append("MAIL_SIZE,");
		sql.append("L_DSP_NO,");
		sql.append("MENU_TYP,");
		sql.append("PSW_TEST,");
		sql.append("USER_AB_ID ");
		sql.append("FROM USR ");
		sql.append("WHERE USER_ID "+((getString("USER_ID").equals(""))?" is null ":"=")+getString("USER_ID")+"");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}

	public int INSERT_USR02(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("	INSERT INTO ");
		sql.append("USR(");
		sql.append("USER_ID,");
		sql.append("USER_NAME,");
		sql.append("PASSWORD,");
		sql.append("CTRL_DVSN_CD,");
		sql.append("AUTH_LEVEL,");
		sql.append("BSNS_TYP,");
		sql.append("MAIL_ADDRESS,");
		sql.append("MAIL_SIZE,");
		sql.append("L_DSP_NO,");
		sql.append("MENU_TYP,");
		sql.append("PSW_TEST,");
		sql.append("USER_AB_ID,");
		sql.append("RGS_DTTM,");
		sql.append("RGS_CHRG_CD,");
		sql.append("RGS_PGID,");
		sql.append("UPD_DTTM,");
		sql.append("UPD_CHRG_CD,");
		sql.append("UPD_PGID,");
		sql.append("PSW_CHANGE_DTTM");
		sql.append(")");
		sql.append("VALUES");
		sql.append("(");
		sql.append(""+getString("USER_ID")+",");
		sql.append(""+getString("USER_NAME")+",");
		sql.append(""+getString("PASSWORD")+",");
		sql.append(""+getString("CTRL_DVSN_CD")+",");
		sql.append(""+getString("AUTH_LEVEL")+",");
		sql.append(""+getString("BSNS_TYP")+",");
		sql.append(""+getString("MAIL_ADDRESS")+",");
		sql.append(""+getString("MAIL_SIZE")+",");
		sql.append(""+getString("L_DSP_NO")+",");
		sql.append(""+getString("MENU_TYP")+",");
		sql.append(""+getString("PSW_TEST")+",");
		sql.append(""+getString("USER_AB_ID")+",");
		sql.append("TO_DATE("+getString("RGS_DTTM")+",'YYYYMMDDHH24MISS'),");
		sql.append(""+getString("RGS_CHRG_CD")+",");
		sql.append(""+getString("RGS_PGID")+",");
		sql.append("TO_DATE("+getString("UPD_DTTM")+",'YYYYMMDDHH24MISS'),");
		sql.append(""+getString("UPD_CHRG_CD")+",");
		sql.append(""+getString("UPD_PGID")+",");
		sql.append("TO_DATE("+getString("UPD_DTTM")+",'YYYYMMDDHH24MISS')");
		sql.append(")");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		int updateCount = db.executeUpdate();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return updateCount;
	}

	public SelectResultRset SELECT_USR03(FrameworkDbCommon db) throws Exception {
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT VDR_CD  ");
		sql.append("FROM M01 ");
		sql.append("WHERE VDR_CD "+((getString("VDR_CD").equals(""))?" is null ":"=")+getString("VDR_CD")+" ");
		sql.append("AND FM_TYP "+((getString("FM_TYP1").equals(""))?" is not null ":"!=")+getString("FM_TYP1")+" ");
		sql.append("AND FM_TYP "+((getString("FM_TYP2").equals(""))?" is not null ":"!=")+getString("FM_TYP2")+" ");
		db.setSql(sql.toString());
		lastSql_ =sql.toString();
		SelectResultRset srr = db.executeQuery();
		paramsString     = new Hashtable();
		paramsBigDecimal = new Hashtable();
		paramsFree       = new Hashtable();

		return srr;
	}


	public void setUSER_ID(String value){
		if(value==null) {
			paramsString.remove("USER_ID");
			return;
		}
		paramsString.put("USER_ID",value);
	}


	public void setUSER_NAME(String value){
		if(value==null) {
			paramsString.remove("USER_NAME");
			return;
		}
		paramsString.put("USER_NAME",value);
	}


	public void setPASSWORD(String value){
		if(value==null) {
			paramsString.remove("PASSWORD");
			return;
		}
		paramsString.put("PASSWORD",value);
	}


	public void setCTRL_DVSN_CD(String value){
		if(value==null) {
			paramsString.remove("CTRL_DVSN_CD");
			return;
		}
		paramsString.put("CTRL_DVSN_CD",value);
	}


	public void setAUTH_LEVEL(String value){
		if(value==null) {
			paramsString.remove("AUTH_LEVEL");
			return;
		}
		paramsString.put("AUTH_LEVEL",value);
	}


	public void setBSNS_TYP(String value){
		if(value==null) {
			paramsString.remove("BSNS_TYP");
			return;
		}
		paramsString.put("BSNS_TYP",value);
	}


	public void setMAIL_ADDRESS(String value){
		if(value==null) {
			paramsString.remove("MAIL_ADDRESS");
			return;
		}
		paramsString.put("MAIL_ADDRESS",value);
	}


	public void setMAIL_SIZE(String value){
		if(value==null) {
			paramsString.remove("MAIL_SIZE");
			return;
		}
		paramsString.put("MAIL_SIZE",value);
	}


	public void setL_DSP_NO(String value){
		if(value==null) {
			paramsString.remove("L_DSP_NO");
			return;
		}
		paramsString.put("L_DSP_NO",value);
	}


	public void setMENU_TYP(String value){
		if(value==null) {
			paramsString.remove("MENU_TYP");
			return;
		}
		paramsString.put("MENU_TYP",value);
	}


	public void setPSW_TEST(String value){
		if(value==null) {
			paramsString.remove("PSW_TEST");
			return;
		}
		paramsString.put("PSW_TEST",value);
	}


	public void setUSER_AB_ID(String value){
		if(value==null) {
			paramsString.remove("USER_AB_ID");
			return;
		}
		paramsString.put("USER_AB_ID",value);
	}


	public void setRGS_DTTM(String value){
		if(value==null) {
			paramsString.remove("RGS_DTTM");
			return;
		}
		paramsString.put("RGS_DTTM",value);
	}


	public void setRGS_CHRG_CD(String value){
		if(value==null) {
			paramsString.remove("RGS_CHRG_CD");
			return;
		}
		paramsString.put("RGS_CHRG_CD",value);
	}


	public void setRGS_PGID(String value){
		if(value==null) {
			paramsString.remove("RGS_PGID");
			return;
		}
		paramsString.put("RGS_PGID",value);
	}


	public void setUPD_DTTM(String value){
		if(value==null) {
			paramsString.remove("UPD_DTTM");
			return;
		}
		paramsString.put("UPD_DTTM",value);
	}


	public void setUPD_CHRG_CD(String value){
		if(value==null) {
			paramsString.remove("UPD_CHRG_CD");
			return;
		}
		paramsString.put("UPD_CHRG_CD",value);
	}


	public void setUPD_PGID(String value){
		if(value==null) {
			paramsString.remove("UPD_PGID");
			return;
		}
		paramsString.put("UPD_PGID",value);
	}


	public void setVDR_CD(String value){
		if(value==null) {
			paramsString.remove("VDR_CD");
			return;
		}
		paramsString.put("VDR_CD",value);
	}


	public void setFM_TYP1(String value){
		if(value==null) {
			paramsString.remove("FM_TYP1");
			return;
		}
		paramsString.put("FM_TYP1",value);
	}


	public void setFM_TYP2(String value){
		if(value==null) {
			paramsString.remove("FM_TYP2");
			return;
		}
		paramsString.put("FM_TYP2",value);
	}


}
